function checkForm(){ 
    var nametip = checkUserName(); 
    var emailtip = checkEmail();
    var passtip = checkPassword();  
    var conpasstip = confirmPassword(); 
    var phonetip = checkPhone(); 
    return nametip && passtip && conpasstip && phonetip; 
} 
function checkUserName(){
	var username=document.getElementById('userName');
	var errname = document.getElementById('errName'); 
	var pattern = /^\w{3,}$/;
	if(username.value.length == 0){ 
    errname.innerHTML="用户名不能为空"
    errname.className="error"
    return false; 
	}
	if(!pattern.test(username.value)){ 
    errname.innerHTML="用户名不合规范，应至少为3位"
    errname.className="error"
    return false; 
    } 
    else{ 
    errname.innerHTML="OK"
    errname.className="success"; 
    return true; 
    } 
}
function checkEmail(){
	var email=document.getElementById('email');
	var erremail=document.getElementById('errEmail');
	var pattern=/^(\w)+(\.\w+)*@(\w)+((\.\w+)+)$/;
	if(email.value.length == 0){ 
    errEmail.innerHTML="电子邮箱不能为空"
    errEmail.className="error"
    return false; 
    }
	if(!pattern.test(email.value)){ 
    errEmail.innerHTML="电子邮箱不合规范，请检查您是否输入正确"
    errEmail.className="error"
    return false; 
    } 
    else{ 
    errEmail.innerHTML="OK"
    errEmail.className="success"; 
    return true; 
    } 
}
function checkPhone(){ 
  var userphone = document.getElementById('userPhone'); 
  var phoneErr = document.getElementById('errPhone'); 
  var pattern = /^1[123456789]\d{9}$/; 
  if(userPhone.value.length == 0){ 
    errPhone.innerHTML="手机号码不能为空"
    errPhone.className="error"
    return false; 
    }
  if(!pattern.test(userphone.value)){ 
    errPhone.innerHTML="手机号码不合规范,请检查您是否输入正确"
    errPhone.className="error"
    return false; 
    } 
   else{ 
    errPhone.innerHTML="OK"
    errPhone.className="success"; 
    return true; 
    } 
} 
function checkPassword(){ 
  var userpasswd = document.getElementById('userPassword'); 
  var errPasswd = document.getElementById('errPassword'); 
  var pattern = /^[A-Za-z0-9]{6,20}$/; 
  if(userpasswd.value.length == 0){ 
    errPassword.innerHTML="密码不能为空"
    errPassword.className="error"
    return false; 
    }
  if(!pattern.test(userpasswd.value)){ 
    errPassword.innerHTML="密码不合规范"
    errPassword.className="error"
    return false; 
    } 
   else{ 
     errPassword.innerHTML="OK"
     errPassword.className="success"; 
     return true; 
     } 
  } 
function confirmPassword(){ 
  var userpasswd = document.getElementById('userPassword'); 
  var userConPassword = document.getElementById('userConfirmPassword'); 
  var errConPasswd = document.getElementById('errConPass'); 
  if((userpasswd.value)!=(userConPassword.value) || userConPassword.value.length == 0){ 
    errConPasswd.innerHTML="上下密码不一致"
    errConPasswd.className="error"
    return false; 
    } 
   else{ 
     errConPasswd.innerHTML="OK"
     errConPasswd.className="success"; 
     return true; 
     }    
  } 
while(1){
  if(!checkForm()){
	document.getElementById('submit').disabled=true;
	document.getElementById('submit').className="cancel";
  }
  else{
	document.getElementById('submit').disabled=false;
	document.getElementById('submit').className="submit";
  }
}